<?php

/**
 * [PHPFOX_HEADER]
 */
defined('PHPFOX') or exit('No direct script access allowed.');

/**
 *
 *
 */
class Profiles_Component_Controller_Manageinvite extends Phpfox_Component {

	public function process()
	{
        $notification_id = $this->request()->get('req3');
        if($aVals = $this->request()->get('val')){
            Phpfox::getService('profiles.process')->acceptInvite($aVals);
            $this->url()->send();
        }
        $req5 = $this->request()->get('req5');
        $sender_id = $this->request()->get('req3');
        $item_id = $this->request()->get('req4');
        if($req5 == 'accept'){
            Phpfox::setCookie('profiles_invite_itemid', $item_id, time()+3600*2);
            Phpfox::getService('profiles.process')->acceptNotification4($sender_id, $item_id);
            $this->url()->send('user.register');
        }elseif($req5 == 'refuse'){
//            Phpfox::getService('profiles.process')->refuseNotification4($sender_id, $item_id);
            $this->url()->send('');
        }
        $invite_message = Phpfox::getService('profiles.process')->getInviteMessage($notification_id);
        $this->template()
            ->assign(array(
                'notification_id' => $notification_id,
                'invite_message' => $invite_message
            )
        );
	}

}